﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<GalleryImageListPaginationViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
    <title>
        <%= Model.Localize("GalleryImagesPageTitle")%></title>
    <%= Html.GetCssFile(Url.GetModuleCssPath("MvcEngine.Gallery.BackOffice.css")) %>
</asp:Content>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page-title" id="post-header">
        <h1>
            <%= Model.Localize("GalleryImagesPageHeader")%></h1>
    </div>
    <div class="page-menu">
        <%= Html.UrlActionLink(Model.Localize("BackLink"), Url.Galleries())%>
        |
        <%= Html.UrlActionLink(Model.Localize("NewImageLink"), "javascript:void(0);", "EditImage('" + Url.NewImage() + "');return false;")%>|
        <%= Html.UrlActionLink(Model.Localize("SettingsLink"), Url.GallerySettings()) %> |
        <%= Html.UrlActionLink(Model.Localize("CategoriesPageLink"), Url.GalleryCategories())%> |
    </div>
    <div>
        <% if (!Model.IsCorrectPage)
           {
        %>
        <%= Model.Localize("ImageInvalidPage")%>
        <%
            }
           else if (Model.Images.Count > 0)
           { %>
        <%= Html.Grid(Model.Images).Columns(column =>
        {
            column.For(x => Html.GetPartial("RowDetails", x)).Header("Title").DoNotEncode();
            column.For(x => Html.GetPartial("CategoriesColumn", x)).Header("Categories").DoNotEncode();
        }).Attributes(cellSpacing => "0", cellPadding => "0", border => "0")
        .Footers(footer => 
          {
              footer.For(Model.Localize("PagesLabel") + Model.TotalPages.GetPaging(p => Html.UrlActionLink(p.ToString(), Url.ImagePage(p)) + "&nbsp;")).DoNotEncode().Attributes(colspan => "1");
              footer.For(string.Format(Model.Localize("TotalItems"), Model.Images.Count));
          })%>
        <%}
           else
           { %>
        <%= Model.Localize("ImageEmptyListMessage")%>
        <%} %>
    </div>
    <div id="dialog" title="<%= Model.Localize("NewImageLabel") %>">
    </div>

    <script type="text/javascript">
        function EditImage(url) {
            $.get(url, null, function(data) {
                $('#dialog').html("");
                $('#dialog').html(data);
                $('#dialog').dialog('open');
            }, "text");
        }
    </script>

</asp:Content>
